package com.project.sevice.impl;

import com.project.sevice.IManService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.time.LocalDate;

/**
 * @Author(王思翰)
 * @Description(类的描述)
 * @Date(创建时间) 2021/7/19 19:38
 */
@Controller
public class GaiServlet extends HttpServlet {
    @Autowired
    private IManService service;

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;charset=utf-8");

        String birthday=req.getParameter("birthday");
        String id=req.getParameter("id");
        service.update(Integer.parseInt(id), LocalDate.parse(birthday));

        resp.sendRedirect("/findAll");
    }
}
